package net.hn.hnms.biz.emgcy.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.hn.hnms.biz.emgcy.domain.EventHarmLevelPo;
import net.hn.hnms.biz.emgcy.domain.dto.EventHarmLevelDto;
import net.hn.hnms.biz.emgcy.domain.vo.EventHarmLevelVo;
import net.hn.hnms.biz.emgcy.service.EventHarmLevelService;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.sys.common.core.domain.ResponsePage;
import net.hn.hnms.sys.common.mybatis.core.page.PageQuery;
import net.hn.hnms.sys.common.satoken.config.AutoSetMineCode;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: baijiajun
 * @Date: 2022/9/9
 */
@Api(value = "灾害等级模块", tags = {"灾害等级模块"})
@RestController
@RequestMapping("eventHarmLevel")
public class EventHarmLevelController {
    @Resource
    private EventHarmLevelService eventHarmLevelService;

    @ApiOperation("事件灾害等级列表")
    @GetMapping("pageList")
    @AutoSetMineCode
    public R<ResponsePage<EventHarmLevelVo>> pageList(PageQuery pageQuery, EventHarmLevelDto eventHarmLevelDto) {
        ResponsePage<EventHarmLevelVo> list=eventHarmLevelService.pageList(pageQuery,eventHarmLevelDto);
        return R.ok(list);
    }

    @ApiOperation("事件灾害等级添加")
    @PostMapping("/add")
    public R add(@RequestBody EventHarmLevelPo eventHarmLevelPo){
        Boolean flag = eventHarmLevelService.add(eventHarmLevelPo);
        if(flag){
            return R.ok("新增成功");
        }
        return R.fail("新增失败");
    }

    @ApiOperation("事件灾害等级修改")
    @PutMapping("/update")
    public R update(@RequestBody EventHarmLevelPo eventHarmLevelPo){
        Boolean flag = eventHarmLevelService.update(eventHarmLevelPo);
        if(flag){
            return R.ok("修改成功");
        }
        return R.fail("修改失败");
    }
    @ApiOperation("事件灾害等级删除")
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable Long id){
        Boolean flag = eventHarmLevelService.delete(id);
        if(flag){
            return R.ok("删除成功");
        }
        return R.fail("删除失败");
    }


}
